use "C:\Users\Amzad\Dropbox\College Construction\Replication-file-JHR\Data\Pop_proj_All_Exponential_StateGR.dta", clear
rename DistPop_All_09 DistPop_All_9
rename DistPop_All_08 DistPop_All_8
rename DistPop_All_07 DistPop_All_7
rename DistPop_All_06 DistPop_All_6
rename DistPop_All_05 DistPop_All_5
rename DistPop_All_04 DistPop_All_4
rename DistPop_All_03 DistPop_All_3
rename DistPop_All_02 DistPop_All_2
rename DistPop_All_01 DistPop_All_1
rename DistPop_All_00 DistPop_All_0
keep districtcode DistPop_All_*
reshape long DistPop_All_, i(districtcode) j(time)
gen year=1900+time if time>=80
replace year=2000+time if time<=21
save "C:\Users\Amzad\Dropbox\College Construction\Replication-file-JHR\Data\pop_projection_exponential.dta", replace

cd "C:\Users\Amzad\Dropbox\College Construction\Replication-file-JHR\Data"
use "C:\Users\Amzad\Dropbox\College Construction\Replication-file-JHR\Data\college_institutions_2018.dta", clear
merge m:1 district_code using split_district.dta
drop if _merge==2
drop _merge
merge m:1 districtcode using treatment.dta
drop _merge
merge m:1 districtcode using ger_640_districts.dta
tab management_id, gen(management_)
bys districtcode year_of_establishment:egen college_central_gov=sum( management_1)
bys districtcode year_of_establishment:egen college_state_gov=sum( management_2)
bys districtcode year_of_establishment:egen college_local_body=sum( management_3)
bys districtcode year_of_establishment:egen college_university=sum( management_4)
bys districtcode year_of_establishment:egen college_private_aided=sum( management_5)
bys districtcode year_of_establishment:egen college_private_nonaided=sum( management_6)
bys districtcode year_of_establishment:keep if _n==1
xtset districtcode year_of_establishment
sum college_central_gov- college_private_nonaided
egen college_constructed=rsum( college_central_gov- college_private_nonaided)
collapse (sum) college_central_gov college_state_gov college_local_body college_university college_private_aided college_private_nonaided college_constructed (  first) ger state_code district_code, by( districtcode year_of_establishment)
keep districtcode year_of_establishment college_constructed ger
drop if year_of_establishment==.
reshape wide college_constructed, i( districtcode) j( year_of_establishment)
egen total_collge_1980=rsum( college_constructed1302- college_constructed1980)
egen total_collge_1981=rsum( college_constructed1302- college_constructed1981)
egen total_collge_1982=rsum( college_constructed1302- college_constructed1982)
egen total_collge_1983=rsum( college_constructed1302- college_constructed1983)
egen total_collge_1984=rsum( college_constructed1302- college_constructed1984)
egen total_collge_1985=rsum( college_constructed1302- college_constructed1985)
egen total_collge_1986=rsum( college_constructed1302- college_constructed1986)
egen total_collge_1987=rsum( college_constructed1302- college_constructed1987)
egen total_collge_1988=rsum( college_constructed1302- college_constructed1988)
egen total_collge_1989=rsum( college_constructed1302- college_constructed1989)
egen total_collge_1990=rsum( college_constructed1302- college_constructed1990)
egen total_collge_1991=rsum( college_constructed1302- college_constructed1991)
egen total_collge_1992=rsum( college_constructed1302- college_constructed1992)
egen total_collge_1993=rsum( college_constructed1302- college_constructed1993)
egen total_collge_1994=rsum( college_constructed1302- college_constructed1994)
egen total_collge_1995=rsum( college_constructed1302- college_constructed1995)
egen total_collge_1996=rsum( college_constructed1302- college_constructed1996)
egen total_collge_1997=rsum( college_constructed1302- college_constructed1997)
egen total_collge_1998=rsum( college_constructed1302- college_constructed1998)
egen total_collge_1999=rsum( college_constructed1302- college_constructed1999)
egen total_collge_2000=rsum( college_constructed1302- college_constructed2000)
egen total_collge_2001=rsum( college_constructed1302- college_constructed2001)
egen total_collge_2002=rsum( college_constructed1302- college_constructed2002)
egen total_collge_2003=rsum( college_constructed1302- college_constructed2003)
egen total_collge_2004=rsum( college_constructed1302- college_constructed2004)
egen total_collge_2005=rsum( college_constructed1302- college_constructed2005)
egen total_collge_2006=rsum( college_constructed1302- college_constructed2006)
egen total_collge_2007=rsum( college_constructed1302- college_constructed2007)
egen total_collge_2008=rsum( college_constructed1302- college_constructed2008)
egen total_collge_2009=rsum( college_constructed1302- college_constructed2009)
egen total_collge_2010=rsum( college_constructed1302- college_constructed2010)
egen total_collge_2011=rsum( college_constructed1302- college_constructed2011)
egen total_collge_2012=rsum( college_constructed1302- college_constructed2012)
egen total_collge_2013=rsum( college_constructed1302- college_constructed2013)
egen total_collge_2014=rsum( college_constructed1302- college_constructed2014)
egen total_collge_2015=rsum( college_constructed1302- college_constructed2015)
egen total_collge_2016=rsum( college_constructed1302- college_constructed2016)
egen total_collge_2017=rsum( college_constructed1302- college_constructed2017)
egen total_collge_2018=rsum( college_constructed1302- college_constructed2018)

keep districtcode college_constructed1980- college_constructed2018 total_collge_1980- total_collge_2018 ger
reshape long total_collge_ college_constructed, i( districtcode) j(year)
rename total_collge_ total_college
replace college_constructed=0 if college_constructed==.
merge m:1 districtcode using treatment.dta
keep if _merge==3
drop _merge
merge m:1 districtcode using ger_640_districts.dta
keep if _merge==3
drop _merge
 
merge 1:1 districtcode year using nightlight_92_2016_v1.dta
drop _merge
merge m:m districtcode using poverty_2011.dta
drop _merge
merge 1:1 districtcode year using pop_projection_exponential.dta
drop if _merge==2

gen nlight_avg2016= nightlight_annual if year==2016
bys districtcode: egen nightlight_avg2016 =sum( nlight_avg2016 )
*drop if year<1985
gen college_percapita=(total_college/DistPop_All_)*100000
gen new_college_percapita=(college_constructed/DistPop_All_)*100000

